import request from '../../utils/request'
const apiHeader = 'apiManage'

// 分组列表查询
export function getGroupList(data, projectId, parentId) {
  return request({
    url: `${apiHeader}/ApiGroupInfo/treeSelectByParentId?projectId=${projectId}&parentId=${parentId}`,
    method: 'post',
    data
  })
}
// 新增分组
export function addGroupItem(data) {
  return request({
    url: `${apiHeader}/ApiGroupInfo`,
    method: 'post',
    data
  })
}
// 编辑分组
export function editGroupItem(data, id) {
  return request({
    url: `${apiHeader}/ApiGroupInfo/` + id,
    method: 'put',
    data
  })
}
// 删除分组
export function deleteGroupItem(id) {
  return request({
    url: `${apiHeader}/ApiGroupInfo`,
    method: 'delete',
    data: { id: id }
  })
}
// 新建api
export function addApiItem(data) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/insertAll`,
    method: 'post',
    data
  })
}
// 查询API列表
export function getAPIList(data, groupId, projectId) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/selectListByGroupId?groupId=${groupId}&projectId=${projectId}`,
    method: 'post',
    data
  })
}
// 查询api单条信息
export function getApiListDetalis(data) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/selectAllAndUpdateCache?apiId=${data.apiId}`,
    method: 'post',
    data
  })
}
// api更新
export function apiListUpload(data, id) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/updateAll?apiId=${id.apiId}`,
    method: 'post',
    data
  })
}
// 删除API
export function deleteAPIItem(id) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/deleteByBatch`,
    method: 'delete',
    data: { apiIds: [
      `${id}`
    ]
    }
  })
}
// 彻底删除API
export function deletecompletely(id) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/deleteForceByBatch`,
    method: 'delete',
    data: { apiIds: [
      `${id}`
    ]
    }
  })
}
// 批量删除 彻底删除API
export function deletecompletelyAll(arrId) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/deleteForceByBatch`,
    method: 'delete',
    data: { apiIds: arrId }
  })
}
// 恢复API
export function recoverysave(id, groupId) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/recoverByBatch`,
    method: 'post',
    data: { apiIds: [
      `${id}`
    ],
    groupId: groupId
    }
  })
}
// 编辑API详情页接口数据
export function EdithistoryList(apiId) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/selectHistoryList?apiId=${apiId}`,
    method: 'post'
  })
}
// 编辑API详情页编辑历史列表
export function geteditdata(apiId) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/selectAllAndUpdateCache?apiId=${apiId}`,
    method: 'post'
  })
}
// 修改状态
export function editstatusSave(apiId, status) {
  return request({
    url: `${apiHeader}//ApiBaseInfo/updateStatusByBatch`,
    method: 'post',
    data: { apiIds: [
      `${apiId}`
    ],
    status: status
    }
  })
}
// api复制
export function copyApi(data) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/copyApi`,
    method: 'post',
    data
  })
}
// 新增数据结构
export function addApiDataStructure(data) {
  return request({
    url: `${apiHeader}/ApiDataStructure`,
    method: 'post',
    data
  })
}
// 数据结构查询
export function getdatastructureList(data, isGlobal, projectId) {
  return request({
    url: `${apiHeader}/ApiDataStructure/selectListByProjectId?isGlobal=${isGlobal}&projectId=${projectId}`,
    method: 'post',
    data
  })
}
// 数据结构详情
export function Editdatastructure(id) {
  return request({
    url: `${apiHeader}/ApiDataStructure/` + id,
    method: 'get'
  })
}
// 数据结构编辑保存
export function Editdatastructuresave(data, id) {
  return request({
    url: `${apiHeader}/ApiDataStructure/` + id,
    method: 'put',
    data
  })
}
// 数据结构删除
export function datadelete(data) {
  return request({
    url: `${apiHeader}/ApiDataStructure/deleteByBatch`,
    method: 'delete',
    data
  })
}
// 数据结构删除
export function databulkdelete(data) {
  return request({
    url: `${apiHeader}/ApiDataStructure/deleteForceByBatch`,
    method: 'delete',
    data
  })
}
// 数据结构查看引用
export function viewReferences(data, id) {
  return request({
    url: `${apiHeader}/ApiDataStructure/selectQuotedListById/` + id,
    method: 'post',
    data
  })
}
// 批量修改状态
export function editbulkstatus(data) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/updateStatusByBatch`,
    method: 'post',
    data
  })
}

// 批量复制
export function bulkCopysave(data) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/copyApiByBatch`,
    method: 'post',
    data
  })
}

// 批量移动
export function bulkMovesave(data) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/moveByBatch`,
    method: 'post',
    data
  })
}

// 批量删除
export function bulkdelete(data) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/deleteByBatch`,
    method: 'post',
    data
  })
}

// 批量标记
export function onsign(data) {
  return request({
    url: `${apiHeader}/ApiBaseInfo/updateStarredByBatch`,
    method: 'post',
    data
  })
}
